<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>addEventListener()</title>
</head>
<body>
    <button>change color</button>
    <script>
        var btn = document.querySelector('button');
        function random(number){
            return Math.floor(Math.random()*(number+1))
        }
        function bgChange(e){
            console.log(e)
            var rndCol = 'rgb('+random(255)+','+random(255)+','+random(255)+')';
            // document.body.style.backgroundColor = rndCol;
            e.target.style.backgroundColor = rndCol;
        }
        btn.addEventListener('click', bgChange);
        setTimeout(() => {
            btn.removeEventListener('click', bgChange);      
        }, 5000);
    </script>
</body>
</html>
